<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->theme->baseUrl; ?>/css/task.css" />
<link rel='stylesheet' type='text/css' href="<?php echo Yii::app()->theme->baseUrl; ?>/css/jquery-ui-1.8.14.custom.css" />
<script type='text/javascript' src="<?php echo Yii::app()->theme->baseUrl; ?>/fullCalendar/jquery/jquery-ui-1.8.11.custom.min.js"></script>
<script type='text/javascript' src="<?php echo Yii::app()->theme->baseUrl; ?>/js/jquery.ui.datepicker.js"></script>
<script type="text/javascript">

	$(document).ready(function(){
		$('.popupCancel').click(function(){
			$.fancybox.close();
			return false;
		});
		$('.editTaskTime').datepicker();
	});
</script>

<?php
    // get parameter
    $pid = Yii::app()->request->getParam("pid");
    $tid = Yii::app()->request->getParam("tid");
    //js
    //Generate link for ajax call
    $link = $this->createUrl("tasks/createComment");
    $jsAddComment = "
        $(\"form\").submit(function(){
            $.ajax({
                url: '$link',
                type: 'POST',
                data: {
                    commentBody:$(\"#commentBody_Task\").val(),
                    pid:$pid,
                    tid:$tid,
                },
                success: function(data){
                    $(\"#tdCommentWrapper\").append(data);
                    $(\"#commentBody_Task\").val('');
                }
            });
            return false;
        });
    ";
    Yii::app()->clientScript->registerScript('jsAddComment',$jsAddComment,CClientScript::POS_READY);
    
?>

<script>
	$(document).ready(function(){
		$("#comment-wrapper").load('<?php echo $this->createUrl('/comment/index',array('pid'=>$pid,'oid'=>$tid,'ctype'=>'TASK'))?>'	);
	});
</script>



<div class="clear"></div>


		<div id="than">	
           	 <img src="<?php echo Html::imageUrl("muiten.png");?>" width="27" height="26"; style="float:left">
            	<div id="textxanhdam"> Tasks </div>	
			</div>
	
            <div class="padding15"></div>
             	           	
	             	<!-- Begin leftSidebar-->   
					<div id="leftSidebar">
						<div id="leftWrapper">
							Assigned by</br>
							<span class="taskInfo"><?php echo $task->listAssignmentName()?></span>
							<div class="padding20"></div> 
							Date assigned</br>
							<span class="taskInfo"><?php echo Html::formatDate($task->task_created_date)?></span>
							<div class="padding20"></div>
							Completed by</br>
							<span class="taskInfo"><?php echo $task->taskCreatedByUser->user_name;?></span>
							<div class="padding20"></div>
							Date completed</br>
							<span class="taskInfo"><?php echo Html::formatDate($task->task_completed_date)?></span>
							<div class="padding20"></div>
							Last updated</br>
							<span class="taskInfo"><?php echo Html::formatDate($task->task_updated_date)?></span>
						</div>
					<!-- End leftSidebar -->
					</div>
					<!-- Begin rightSidebar -->
					<div id="rightSidebar">
						<div id="rightHeader">
								<h2><?php echo $task->task_name;?></h2>
								<div class="tdControl">
		                			<a class="tdEditLink" href="#tdEdit">Edit</a>
		                			<a class="tdDeleteLink" href="#">Delete</a>
		                		</div>
						</div>
						<div id="rightWrapper">
							
							<div id="taskDetailBlock">
								<h4>Comments and files on this task from <a href="<?php $this->createUrl("tasks/index",array('pid'=>$pid));?>" class="taskListLink"><?php echo $task->taskTaskList->task_list_name;?></a></h4>
								<div id="subTaskDetailBlock">
									<form action="" method="post">
										<input type="checkbox"><span style="font-weight: bold;">Bùi Xuân Sơn + 7 more:</span> Chọn theme nào</input>
									</form>
								</div>
								<div class="padding20"></div>
								<p><?php echo $task->task_description;?></p>
							</div>
							<div class="padding20"></div>
							<hr size="1px" type="solid" width="100%" color="#F1F1F1"></hr>
							<div class="padding20"></div>
							
							<div id="tdCommentWrapper">
								<div id="comment-wrapper">
									<!--  Load by jquery -->
								</div>
						</div>
                                            
					<!-- End rightSidebar -->
					</div>
				
    </div>
    
    <!-- Edit task popup -->
    <div id="editTaskPopup" style="display: none;">
    	<div id="tdEdit" class="popupWrapper" action="" method="post">
    		<div class="popupHeader">
    			<h2>Edit task</h2>
    		</div>
    		<div class="popupContent">
    			<h3>What needs to be done?</h3>
    			<div class="padding5"></div>
    			<form method="post" action="">
    				<input type="text" class="editTaskName" style="width: 60%"></input>
    			
    				<div id="priority" style="float:right;">
    				Priority 
    				<select>
    					<option value="0" selected>No Priority Selected</option>
    					<option value="1">Low</option>
    					<option value="2">Medium</ontion>
    					<option value="3">High</option>
    				</select>
    				</div>
    				<div class="padding5"></div>
    				<p>Who should do this?</p>
    				<select>
    					<option value="0" selected>Tran Huy Chung</option>
    					<option value="1">Tran Ngoc Cuong</option>
    					<option value="2">Dang Thanh Tu</ontion>
    					<option value="3">Bui Xuan Son</option>
    				</select>
    				<a href="#multiPeople" id="multipeople" style="text-decoration: underline;"> Multiple people</a>
    				<input type="text" value="" id = "listPeople" >
    				
    				<p>Complete by ?</p>
    				
    				<input type="text" class="editTaskTime" style="width: 30%"></input>
    				
    				
    				<div class="padding5"></div>
    				<p>Description</p>
    				<textarea rows="4" cols="70"></textarea>
    				<div class="padding5"></div>
    				<div class="postButton">
    					<input type="submit" value="Save this task" /> or
		    			<a href="#" class="popupCancel" >Cancel</a>
    				</div>
    			</form>
    		</div>
    	</div>
    </div>
    
    <!-- Multiple people -->
    <div id="multiPeopleDiv" style="display: none;">
    	<div id="multiPeople" class="megaWrapper" action="" method="post">
    		<div class="megaHeader">
    			<h2>Team</h2>
    			<a id="all" href="#">All</a>
    			<a id="none" href="#">None</a>
    		</div>
    		<div class="popupContent">
			    		<INPUT NAME="options" TYPE="CHECKBOX" VALUE="o1" id="1">
			 					 Option 1<BR>
						<INPUT NAME="options" TYPE="CHECKBOX" VALUE="o2" id="2">
			 					Option 2<BR>
						<INPUT NAME="options" TYPE="CHECKBOX" VALUE="o3">
						  		Option 3<BR>
						<INPUT NAME="options" TYPE="CHECKBOX" VALUE="o4">
						 		 Option 4<BR>
						<INPUT NAME="options" TYPE="CHECKBOX" VALUE="o5">
						 		 Option 5<BR>
						<INPUT NAME="options" TYPE="CHECKBOX" VALUE="o6">
								  Option 6<BR>
						    		
    		</div>
    		<div class="postButton">
    				
    					<button  type="submit" id="multiSave" href="#addTask" >Save</button> 
    					<button id = "clear" href="#addTask">Clear Data</button> 
    					<button id = "back" href="#tdEdit">Back</button> 
		    			
    				</div>
    	</div>
    </div>
    
    <?php  $this->widget('application.extensions.fancybox.EFancyBox', array( 'target'=>'button#back', 'config'=>array( 'scrolling' => 'no', 'titleShow' => false,  'hideOnOverlayClick' =>false ), ) ); ?>
    <?php  $this->widget('application.extensions.fancybox.EFancyBox', array( 'target'=>'a.tdEditLink', 'config'=>array( 'scrolling' => 'no', 'titleShow' => false,  'hideOnOverlayClick' =>false ), ) ); ?>
    <?php  $this->widget('application.extensions.fancybox.EFancyBox', array( 'target'=>'button#multiSave', 'config'=>array( 'scrolling' => 'no', 'titleShow' => false,  'hideOnOverlayClick' =>false ), ) ); ?>
    <?php  $this->widget('application.extensions.fancybox.EFancyBox', array( 'target'=>'a#multipeople', 'config'=>array( 'scrolling' => 'no', 'titleShow' => false,  'hideOnOverlayClick' =>false ), ) ); ?>
			